﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using app.Common.recommendUtil;

namespace app.Api
{
    #region 返回结果类，用于文本相似度计算
    public class Result
    {
        int _status = (int)STATUS.OK;
        public int status { get { return _status; } set { _status = value; } }
    }
    public class ObjectResult : Result
    {
        public object data { get; set; }
    }
    public class ListResult<T> : Result
    {
        public List<T> list { get; set; }
    }
    public class PageResult<T> : Result
    {
        public PageData<T> page { get; set; }

        public PageResult() {
            this.page = new PageData<T>();
        }
        //public PageResult<TMap> MapTo<TMap>()
        //{

        //}
        public PageResult<Object> MapToObj(Func<T, object> func)
        {
            PageResult<Object> result = new PageResult<object>();
            result.status = this.status;
            result.page.current_page = this.page.current_page;
            result.page.page_size = this.page.page_size;
            result.page.total = this.page.total;
            result.page.list = this.page.list.Select(r => func(r)).ToList();
            return result;
        }
    }
    public class PageResult : Result
    {
        public PageData page { get; set; }
    }
    public class PageData<T>
    {
        public int current_page { get; set; }
        public int page_size { get; set; }
        public int total { get; set; }
        public List<T> list { get; set; }

        public static implicit operator PageData<T>(PageData<MatchRate> v)
        {
            throw new NotImplementedException();
        }
    }
    public class PageData
    {
        public int current_page { get; set; }
        public int page_size { get; set; }
        public int total { get; set; }
        public object list { get; set; }
    }
    public class IDResult : Result
    {
        public object id { get; set; }
    }
    public class EnumResult : Result
    {
        public int value { get; set; }
        public string name { get; set; }
    }
    public class BooleanResult : Result
    {
        public bool value { get; set; }
        public string message { get; set; }
    }
    public class ValueResult : Result
    {
        public object value { get; set; }
    }
    public class MessageResult : Result
    {
        public string message { get; set; }
    }
    #endregion
}